package com.dgq.main;

import com.dgq.main.config.ApplicationConfig;
import com.dgq.main.service.AccountService;
import com.dgq.main.service.ShippingCart;
import com.dgq.main.service.UserService;
import com.dgq.main.service.impl.UserServiceImpl;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.web.context.request.RequestScope;

import java.lang.reflect.Modifier;

public class Mainstart {

	public final void add(){
		System.out.println();
	}
	public static void main(String[] args) {

		/**
		 * 第一种方式：创建context指定扫描包路径
		 */
//		AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext("com.dgq.main.service");

		/**
		 * 第二种方式：创建context指定配置类
		 */
		AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ApplicationConfig.class);

		/**
		 * 第三种方式：创建context手动register配置类及调用refresh
		 */
//		AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
//		context.register(ApplicationConfig.class);
//		RequestScope scope = new RequestScope();
//		context.getBeanFactory().registerScope("request", scope);
//		context.refresh();
//
//		AccountService accountService = context.getBean(AccountService.class);
//
//		UserService userService = (UserServiceImpl)context.getBean(UserService.class);
//
		AccountService accountService = context.getBean(AccountService.class);

		accountService.addAccount("邓国泉");
	}
}
